package org.ims.inv.web.action.system;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.ims.inv.model.system.ModelAppLog;
import org.ims.inv.web.action.BaseAppAction;

import cn.trymore.core.exception.ServiceException;
import cn.trymore.core.web.paging.PaginationSupport;
import cn.trymore.core.web.paging.PagingBean;

/**
 * Action: 系统日志管理
 * 
 * @author Jeccy.Zhao
 *
 */
public class SystemLogAction
extends BaseAppAction
{
	/**
	 * The LOGGER
	 */
	private static final Logger LOGGER = Logger.getLogger(SystemLogAction.class);
	
	/**
	 * <b>[WebAction]</b> 
	 * <br/>
	 * 系统日志列表
	 */
	public ActionForward pageLogIndex (ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) 
	{
		try
		{
			ModelAppLog entity = (ModelAppLog) form;
			
			PagingBean pagingBean = this.getPagingBean(request, 24);
			PaginationSupport<ModelAppLog> logs = this.serviceAppLog.getPagination(entity, pagingBean);
			
			request.setAttribute("datagrid", logs);
			request.setAttribute("formEntity", entity);
			
			// 输出分页信息至客户端
			outWritePagination(request, pagingBean, logs);
			
		} 
		catch (ServiceException e)
		{
			LOGGER.error("Exception raised when fetch all roles.", e);
		}
		
		return mapping.findForward("page.sys.log.index");
	}
		
	public static Logger getLogger()
	{
		return LOGGER;
	}
}
